package com.pkk.components.common.config.swagger;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

/**
 * @description: 动态刷新配置
 * @author: peikunkun
 * @create: 2019-07-04 13:33
 **/
@Slf4j
@Configuration
//classpath存在此配置才会启用
//@ConditionalOnClass(ConfigChangeEvent.class)
public class DynamicRefreshSwaggerProperties implements ApplicationContextAware {


  private ApplicationContext applicationContext;

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;
  }


  /*@ApolloConfigChangeListener
  public void change(ConfigChangeEvent configChangeEvent) {
    refreshChange(configChangeEvent.changedKeys());
  }

  private void refreshChange(Set<String> changedKeys) {
    log.debug("refresh config swagger config:{}", changedKeys);
    this.applicationContext.publishEvent(new EnvironmentChangeEvent(changedKeys));
  }*/


}
